#include<bits/stdc++.h>
#define int long long
#define N 1505
using namespace std;
int n;
int a[N],r[N],g[N];
int b[N];
int s[N];
const int mod=998244353;
int Pow(int x,int y){
    x%=mod;
    int z=1;
    while(y){
        if(y&1) z=z*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return z;
}
signed main(){
    freopen("traffic.in","r",stdin);
    freopen("traffic.out","w",stdout);
    scanf("%lld",&n);
    int p=1;
    for(int i=1;i<=n;i++){
        scanf("%lld %lld %lld",&a[i],&r[i],&g[i]);
        b[i]=r[i]+g[i];
        p=p/__gcd(p,b[i])*b[i];
    }
    b[n+1]=r[n+1]=1;
    for(int t=0;t<p;t++){
        for(int i=1;i<=n+1;i++){
            int o=(t+a[i])%b[i];
            if(o<r[i]){s[i]++;break;}
        }
    }
    int inv=Pow(p,mod-2);
    for(int i=1;i<=n+1;i++) printf("%lld\n",s[i]*inv%mod);
    return 0;
}